package com.hf.job

import com.hf.bill.MailBillLastWorkdayOfPeriodService
import com.hf.security.SystemConfigService

class BillLastWorkdayOfPeriodJob {

	MailBillLastWorkdayOfPeriodService mailBillLastWorkdayOfPeriodService
	SystemConfigService systemConfigService

	static triggers = {
		// 12:15, last workday of period
		cron name: 'billLastWorkdayOfWeekJob', cronExpression: "0 15 12 ? * 1-7"
	}

	def execute() {
		if (systemConfigService.isBillDayOfPeriod()) {
			// execute job
			log.info "job run!"

			mailBillLastWorkdayOfPeriodService.sendMail()

			log.info "bill email success"
		}
	}
}
